package main.java;

import main.java.constant.ColumnConstant;
import main.java.controller.UserController;
import main.java.dao.UserDao;
import main.java.dao.impl.UserDaoImpl;
import main.java.polo.User;
import main.java.view.UserView;

import java.util.Scanner;

public class test01 {
    public static void main(String[] args) {
        UserView userView = new UserView();
        String userName;
        do {
            userName = UserView.loginView();
        } while (userName == null);
        while (true) {
            userView.mainView();
            ColumnConstant.control=true;
            Scanner scanner = new Scanner(System.in);
            int choice = scanner.nextInt();
            switch (choice) {
                case 1://完善个人信息
                    int result = UserController.update();
                    if (result == 1) {
                        System.out.println("信息完善成功");
                    }else {
                        System.out.println("信息完善失败");
                    }
                    break;
                case 2://预约挂号信息管理
                    UserDao userDao = new UserDaoImpl();
                    User user = userDao.selectByName(userName);
                    if (user.getUserStatus() != 0) {
                        userView.appointmentView();
                    }else{
                        System.out.println("您尚未验证学号，无法进行挂号");
                        System.out.println("请完善个人信息,并等待管理员进行验证");
                    }
                    break;
                case 3://患者信息管理————待完成
                    if(userName.equals(ColumnConstant.columnName))
                        userView.patientView();
                    else
                        System.out.println("权限不足");
                    break;
                case 4://医生信息管理
                    if(userName.equals(ColumnConstant.columnName))
                        userView.doctorView();
                    else
                        System.out.println("权限不足");
                    break;
                case 5:
                    System.out.println("退出登录");
                    return;
                default:
                    System.out.println("输入错误，请重新输入");
            }
        }
    }
}
